package com.net355.eblog.util;

import java.io.Serializable;
import java.util.List;

public class PaginationSupport implements Serializable {

	private static final long serialVersionUID = 9114197240413704592L;

	private int pageSize = 10;

	private int totalCount;

	private int startIndex;

	private int pageCount;

	private List<?> items;

	public PaginationSupport(List<?> items, int totalCount) {
		setTotalCount(totalCount);
		setItems(items);
		setStartIndex(0);

	}

	public PaginationSupport(List<?> items, int totalCount, int startIndex) {
		setTotalCount(totalCount);
		setItems(items);
		setStartIndex(startIndex);

	}

	public PaginationSupport(List<?> items, int totalCount, int pageSize, int startIndex) {
		setPageSize(pageSize);
		setTotalCount(totalCount);
		setItems(items);
		setStartIndex(startIndex);

	}

	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
		this.pageCount=0;
		if (totalCount > 0) {
			this.pageCount = (int)Math.ceil(totalCount/pageSize);
		} 
	}

	public int getTotalCount() {
		return totalCount;
	}

	public int getStartIndex() {
		return startIndex;
	}

	public void setStartIndex(int startIndex) {
		this.startIndex = startIndex;
	}

	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}

	public int getPageCount() {
		return pageCount;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public List<?> getItems() {
		return items;
	}

	public void setItems(List<?> items) {
		this.items = items;
	}

}